package com.woniuxy.hotel.room.mapper;

import com.woniuxy.hotel.room.pojo.Img;
import com.woniuxy.hotel.room.pojo.ImgExample;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

import java.util.List;

public interface ImgMapper {
    @SelectProvider(type = ImgSqlProvider.class, method = "countByExample")
    int countByExample(ImgExample example);
    
    @DeleteProvider(type = ImgSqlProvider.class, method = "deleteByExample")
    int deleteByExample(ImgExample example);
    
    @Delete({
            "delete from img",
            "where imgId = #{imgid,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer imgid);
    
    @Insert({
            "insert into img (imgId, roomId, ",
            "hotelId, imgAddr)",
            "values (#{imgid,jdbcType=INTEGER}, #{roomid,jdbcType=INTEGER}, ",
            "#{hotelid,jdbcType=INTEGER}, #{imgaddr,jdbcType=VARCHAR})"
    })
    int insert(Img record);
    
    @InsertProvider(type = ImgSqlProvider.class, method = "insertSelective")
    int insertSelective(Img record);
    
    @SelectProvider(type = ImgSqlProvider.class, method = "selectByExample")
    @Results({
            @Result(column = "imgId", property = "imgid", jdbcType = JdbcType.INTEGER, id = true),
            @Result(column = "roomId", property = "roomid", jdbcType = JdbcType.INTEGER),
            @Result(column = "hotelId", property = "hotelid", jdbcType = JdbcType.INTEGER),
            @Result(column = "imgAddr", property = "imgaddr", jdbcType = JdbcType.VARCHAR)
    })
    List<Img> selectByExample(ImgExample example);
    
    @Select({
            "select",
            "imgId, roomId, hotelId, imgAddr",
            "from img",
            "where imgId = #{imgid,jdbcType=INTEGER}"
    })
    @Results({
            @Result(column = "imgId", property = "imgid", jdbcType = JdbcType.INTEGER, id = true),
            @Result(column = "roomId", property = "roomid", jdbcType = JdbcType.INTEGER),
            @Result(column = "hotelId", property = "hotelid", jdbcType = JdbcType.INTEGER),
            @Result(column = "imgAddr", property = "imgaddr", jdbcType = JdbcType.VARCHAR)
    })
    Img selectByPrimaryKey(Integer imgid);
    
    @Select({
            "select",
            "imgId, hotelId, imgAddr",
            "from img",
            "where hotelId = #{hotelId,jdbcType=INTEGER}"
    })
    @Results({
            @Result(column = "imgId", property = "imgid", jdbcType = JdbcType.INTEGER, id = true),
            @Result(column = "hotelId", property = "hotelid", jdbcType = JdbcType.INTEGER),
            @Result(column = "imgAddr", property = "imgaddr", jdbcType = JdbcType.VARCHAR)
    })
    List<Img> selectByHotelId(Integer hotelId);
    
    @Select({
            "select",
            "imgId, roomId, imgAddr",
            "from img",
            "where roomId = #{hotelId,jdbcType=INTEGER}"
    })
    @Results({
            @Result(column = "imgId", property = "imgid", jdbcType = JdbcType.INTEGER, id = true),
            @Result(column = "roomId", property = "roomid", jdbcType = JdbcType.INTEGER),
            @Result(column = "imgAddr", property = "imgaddr", jdbcType = JdbcType.VARCHAR)
    })
    List<Img> selectByRoomlId(Integer roomId);
    
    @UpdateProvider(type = ImgSqlProvider.class, method = "updateByExampleSelective")
    int updateByExampleSelective(@Param("record") Img record, @Param("example") ImgExample example);
    
    @UpdateProvider(type = ImgSqlProvider.class, method = "updateByExample")
    int updateByExample(@Param("record") Img record, @Param("example") ImgExample example);
    
    @UpdateProvider(type = ImgSqlProvider.class, method = "updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(Img record);
    
    @Update({
            "update img",
            "set roomId = #{roomid,jdbcType=INTEGER},",
            "hotelId = #{hotelid,jdbcType=INTEGER},",
            "imgAddr = #{imgaddr,jdbcType=VARCHAR}",
            "where imgId = #{imgid,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(Img record);
}